//
//  QZEditSexVC.m
//  WeiWeiHaircut
//
//  Created by 上官惠阳 on 15/12/10.
//  Copyright © 2015年 超群. All rights reserved.
//

#import "QZEditSexVC.h"

@interface QZEditSexVC ()

@end

@implementation QZEditSexVC
{
    NSIndexPath *_seletedIndexPath;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self titleWithSting:@"性别"];
    
    [self addBtnOnNavWithTitle:@"取消" andImageName:@"返回" andTarget:self andAction:@selector(backAction) andFrame:CGRectMake(0, 0, 45, 20) andDirection:left];
    
    [self createTableViewWithPlainStyle:NO andSeparatorStyleNone:YES andBackGroudImageName:nil];
    
    [self registCellWithClassName:[UITableViewCell class] addIdentifier:@"sexCell" addHeight:44];
    
    [self.tableSource addObject:@[@""]];
    [self.tableSource addObject:@[@""]];
    [self.tableView reloadData];
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 15;
    }
    return 6;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.000000001;
}
-(void)loadCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        cell.textLabel.text = @"男";
    }else{
        cell.textLabel.text = @"女";
    }
}
-(void)actionAtIndexPath:(NSIndexPath *)indexPath
{
    _seletedIndexPath = indexPath;
    [self requestWithKeys:@[@"sex",@"user_id"] andValues:@[indexPath.section == 0 ? @(1):@(2),[QZUserInfo userId]] andUrlKey:@"User.GetSetSex" isCache:NO];
}
-(void)request_POST_FinishValue :(id)value tagNSString:(NSString *)tag
{
    NSLog(@"value = %@",value);
    NSLog(@"info = %@",value[@"info"]);
    if ([value[@"data"][@"status"] intValue] == 100) {
        
        [[TMCache sharedCache] setObject:@(_seletedIndexPath.section+1) forKey:@"sex"];
        [self performSelector:@selector(backAction) withObject:nil afterDelay:0.7];
    }
}
-(void)backAction
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
